home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / e33el2.zip / emacs / 19.33 / lisp / browse-url.el < prev    next >
Text File  |  1996-08-04  |  24KB  |  606 lines

  1. ;;; browse-url.el --- ask a WWW browser to load a URL
  2.  
  3. ;; Copyright 1995, 1996 Free Software Foundation, Inc.
  4.  
  5. ;; Author: Denis Howe <dbh@doc.ic.ac.uk>
  6. ;; Maintainer: Denis Howe <dbh@doc.ic.ac.uk>
  7. ;; Created: 03 Apr 1995
  8. ;; Keywords: hypertext
  9. ;; X-Home page: http://wombat.doc.ic.ac.uk/
  10.  
  11. ;; This file is part of GNU Emacs.
  12.  
  13. ;; GNU Emacs is free software; you can redistribute it and/or modify
  14. ;; it under the terms of the GNU General Public License as published by
  15. ;; the Free Software Foundation; either version 2, or (at your option)
  16. ;; any later version.
  17.  
  18. ;; GNU Emacs is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;; GNU General Public License for more details.
  22.  
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with GNU Emacs; see the file COPYING.  If not, write to the
  25. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  26. ;; Boston, MA 02111-1307, USA.
  27.  
  28. ;;; Commentary:
  29.  
  30. ;; The latest version of this package should be available from
  31. ;; <URL:http://wombat.doc.ic.ac.uk/emacs/browse-url.el>.
  32.  
  33. ;; This package provides functions which read a URL (Uniform Resource
  34. ;; Locator) from the minibuffer, defaulting to the URL around point,
  35. ;; and ask a World-Wide Web browser to load it.  It can also load the
  36. ;; URL associated with the current buffer.  Different browsers use
  37. ;; different methods of remote control so there is one function for
  38. ;; each supported browser.  If the chosen browser is not running, it
  39. ;; is started.  Currently there is support for:
  40.  
  41. ;; Function              Browser     Earliest version
  42. ;; browse-url-netscape   Netscape    1.1b1         
  43. ;; browse-url-mosaic     XMosaic     <= 2.4
  44. ;; browse-url-cci        XMosaic     2.5
  45. ;; browse-url-w3         w3          0
  46. ;; browse-url-iximosaic  IXI Mosaic  ?
  47.  
  48. ;; Note that versions of Netscape before 1.1b1 did not have remote
  49. ;; control.  <URL:http://home.netscape.com/newsref/std/x-remote.html>
  50. ;; and <URL:http://home.netscape.com/info/APIs/>.
  51.  
  52. ;; Netscape can cache Web pages so it may be necessary to tell it to
  53. ;; reload the current page if it has changed (eg. if you have edited
  54. ;; it).  There is currently no perfect automatic solution to this.
  55.  
  56. ;; Netscape allows you to specify the id of the window you want to
  57. ;; control but which window DO you want to control and how do you
  58. ;; discover its id?
  59.  
  60. ;; If using XMosaic before version 2.5, check the definition of
  61. ;; browse-url-usr1-signal below.
  62. ;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/remote-control.html>
  63.  
  64. ;; XMosaic version 2.5 introduced Common Client Interface allowing you
  65. ;; to control mosaic through Unix sockets.
  66. ;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/CCI/cci-spec.html>
  67.  
  68. ;; William M. Perry's excellent "w3" WWW browser for
  69. ;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/>
  70. ;; has a function w3-follow-url-at-point, but that
  71. ;; doesn't let you edit the URL like browse-url.
  72.  
  73. ;; I recommend Nelson Minar <nelson@santafe.edu>'s excellent
  74. ;; html-helper-mode.el for editing HTML and thank Nelson for
  75. ;; his many useful comments on this code.
  76. ;; <URL:http://www.santafe.edu/~nelson/hhm-beta/>
  77.  
  78. ;; This package generalises function html-previewer-process in Marc
  79. ;; Andreessen <marca@ncsa.uiuc.edu>'s html-mode (LCD
  80. ;; modes/html-mode.el.Z) and provides better versions of the URL
  81. ;; functions in Michelangelo Grigni <mic@cs.ucsd.edu>'s ffap.el
  82. ;; (find-file-at-point) <URL:ftp://cs.ucsd.edu:/pub/mic/>.  The huge
  83. ;; hyperbole package also contains similar functions.
  84.  
  85. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  86. ;; Help!
  87.  
  88. ;; Can you write and test some code for the Macintrash and Windoze
  89. ;; Netscape remote control APIs?  (See the URL above).
  90.  
  91. ;; Do any other browsers have remote control?
  92.  
  93. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  94. ;; Usage
  95.  
  96. ;; To display the URL at or before point:
  97. ;; M-x browse-url-at-point RET
  98.  
  99. ;; To display a URL by shift-clicking on it, put this in your ~/.emacs
  100. ;; file:
  101. ;;      (global-set-key [S-mouse-2] 'browse-url-at-mouse)
  102. ;; (Note that using Shift-mouse-1 is not desirable because
  103. ;; that event has a standard meaning in Emacs.)
  104.  
  105. ;; To display the current buffer in a web browser:
  106. ;; M-x browse-url-of-buffer RET
  107.  
  108. ;; In Dired, to display the file named on the current line:
  109. ;; M-x browse-url-of-dired-file RET
  110.  
  111. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  112. ;; Customisation (~/.emacs)
  113.  
  114. ;; To see what variables are available for customization, type `M-x
  115. ;; set-variable browse-url TAB'.
  116.  
  117. ;; To bind the browse-url commands to keys with the `C-c u' prefix:
  118. ;;      (global-set-key "\C-cu." 'browse-url-at-point)
  119. ;;      (global-set-key "\C-cub" 'browse-url-of-buffer)
  120. ;;      (global-set-key "\C-cuf" 'browse-url-of-file)
  121. ;;      (add-hook 'dired-mode-hook
  122. ;;                (lambda ()
  123. ;;                  (local-set-key "\C-cuf" 'browse-url-of-dired-file))))
  124. ;;      (if (boundp 'browse-url-browser-function)
  125. ;;          (global-set-key "\C-cuu" browse-url-browser-function)
  126. ;;        (eval-after-load
  127. ;;         "browse-url"
  128. ;;         '(global-set-key "\C-cuu" browse-url-browser-function)))
  129.  
  130. ;; To use the Emacs w3 browser when not running under X11:
  131. ;;      (if (not (eq window-system 'x))
  132. ;;          (setq browse-url-browser-function 'browse-url-w3))
  133.  
  134. ;; To always save modified buffers before displaying the file in a browser:
  135. ;;      (setq browse-url-save-file t)
  136.  
  137. ;; To get round the Netscape caching problem, you could try either of
  138. ;; the following (but not both).  EITHER write-file in
  139. ;; html-helper-mode makes Netscape reload document:
  140. ;;
  141. ;;      (autoload 'browse-url-netscape-reload "browse-url"
  142. ;;        "Ask a WWW browser to redisplay the current file." t)
  143. ;;      (add-hook 'html-helper-mode-hook
  144. ;;                (function (lambda ()
  145. ;;                   (add-hook 'local-write-file-hooks
  146. ;;                             (function (lambda ()
  147. ;;                                (let ((local-write-file-hooks))
  148. ;;                                  (save-buffer))
  149. ;;                                (browse-url-netscape-reload)
  150. ;;                                t))                   ; => file written by hook
  151. ;;                             t))))                    ; append to l-w-f-hooks
  152. ;;
  153. ;; [Does this work for html-mode too?]
  154. ;;
  155. ;; OR browse-url-of-file ask Netscape to load and then reload the
  156. ;; file:
  157. ;;
  158. ;;      (add-hook 'browse-url-of-file-hook 'browse-url-netscape-reload)
  159.  
  160. ;; You may also want to customise browse-url-netscape-arguments, eg.
  161. ;;
  162. ;;      (setq browse-url-netscape-arguments '("-install"))
  163. ;;
  164. ;; or similarly for the other browsers. 
  165.  
  166. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  167. ;;; Change Log:
  168.  
  169. ;; 0.00 03 Apr 1995 Denis Howe <dbh@doc.ic.ac.uk>
  170. ;;      Created.
  171.  
  172. ;; 0.01 04 Apr 1995
  173. ;;      All names start with "browse-url-".  Added provide.
  174.  
  175. ;; 0.02 05 Apr 1995
  176. ;;      Save file at start of browse-url-of-file.
  177. ;;      Use start-process instead of start-process-shell-command.
  178.  
  179. ;; 0.03 06 Apr 1995
  180. ;;      Add browse-url-netscape-reload, browse-url-netscape-command.
  181. ;;      browse-url-of-file save file option.
  182.  
  183. ;; 0.04 08 Apr 1995
  184. ;;      b-u-file-url separate function.  Change b-u-filename-alist
  185. ;;      default.
  186.  
  187. ;; 0.05 09 Apr 1995
  188. ;;      Added b-u-of-file-hook.
  189.  
  190. ;; 0.06 11 Apr 1995
  191. ;;      Improved .emacs suggestions and documentation.
  192.  
  193. ;; 0.07 13 Apr 1995
  194. ;;      Added browse-url-interactive-arg optional prompt.
  195.  
  196. ;; 0.08 18 Apr 1995
  197. ;;      Exclude final "." from browse-url-regexp.
  198.  
  199. ;; 0.09 21 Apr 1995
  200. ;;      Added mouse-set-point to browse-url-interactive-arg.
  201.  
  202. ;; 0.10 24 Apr 1995
  203. ;;      Added Mosaic signal sending variations.
  204. ;;      Thanks Brian K Servis <servis@ecn.purdue.edu>.
  205. ;;      Don't use xprop for Netscape.
  206.  
  207. ;; 0.11 25 Apr 1995
  208. ;;      Fix reading of ~/.mosaicpid.  Thanks Dag.H.Wanvik@kvatro.no.
  209.  
  210. ;; 0.12 27 Apr 1995
  211. ;;      Interacti